package com.atguigu.guli.service.cms.service.impl;

import com.atguigu.guli.service.cms.entity.Ad;
import com.atguigu.guli.service.cms.mapper.AdMapper;
import com.atguigu.guli.service.cms.service.AdService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 广告推荐 服务实现类
 * </p>
 *
 * @author atguigu
 * @since 2021-12-08
 */
@Service
public class AdServiceImpl extends ServiceImpl<AdMapper, Ad> implements AdService {
    @Autowired
    private RedisTemplate redisTemplate ;

    @Override
    @Cacheable(value = "ad",key = "'banners'")
    public List<Ad> getBanners() {
        //从redis查询banner数据,如果有直接查询返回
        //如果redis没有，从数据库查询数据放到redis再返回
        return this.list();
    }
}
